package kevin.socketdemo;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import java.lang.reflect.Proxy;
import java.net.Socket;

/**
 * Hello world!
 *
 */
public class App
{
    public static void main( String[] args )
    {

        SocketClientInstance socketClientInstance = new SocketClientInstance(7878,"127.0.0.1");
        UserData data = new UserData(1,"在吗？");
        SendMeaageImpl sendMessage = new SendMeaageImpl(socketClientInstance,data);

        try {
            ISendMessage impl =(ISendMessage) Proxy.newProxyInstance(SendMeaageImpl.class.getClassLoader(),SendMeaageImpl.class.getInterfaces(),new SocketHanndler(sendMessage));

            System.out.println(impl.hello());
        }catch (Exception e)
        {
            e.printStackTrace();
        }





//        UserData data = new UserData(1,"在吗？");
//        SocketClientInstance socketClientInstance = new SocketClientInstance(7878,"127.0.0.1");
//        Socket socket = socketClientInstance.getSocketInstance();
//
//        try {
////            Socket socket =new Socket("localhost",7878);
//            ObjectOutputStream objectOutputStream = new ObjectOutputStream(socket.getOutputStream());
//            objectOutputStream.writeObject(data);
//            objectOutputStream.flush();
//
//
//            ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());
//            UserData datat=(UserData) inputStream.readObject();
//            System.out.println(datat.toString());
//        }catch (Exception e)
//        {
//            new RuntimeException(e.getMessage());
//        }
////



    }
}
